Skip to content

Fixes #63 : UserDashboard with rich analytics#64

Merged
Kmadhav824 merged 4 commits intoshivamxverma:mainfrom
Kmadhav824:dashboard
May 4, 2026
Merged

Fixes #63 : UserDashboard with rich analytics#64
Kmadhav824 merged 4 commits intoshivamxverma:mainfrom
Kmadhav824:dashboard

Conversation

@Kmadhav824
Copy link
Copy Markdown
Collaborator

Clicking on dashboard leads to a user dashboard page with rich analytics for users to see their submissions and problem count.

Copilot AI review requested due to automatic review settings May 4, 2026 18:36
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

@Kmadhav824 is attempting to deploy a commit to the Shivam verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Kmadhav824 Kmadhav824 merged commit 6f06af2 into shivamxverma:main May 4, 2026
5 of 6 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new authenticated “User Dashboard” view that surfaces user-specific analytics (submission activity and solved counts) by introducing a new backend endpoint and wiring a new frontend route/UI.

Changes:

  • Added GET /submission/user/dashboard endpoint to return recent submissions plus solved/submission aggregates.
  • Implemented a new UserDashboard React page with stats cards, difficulty breakdown, and a recent submissions list.
  • Added a protected frontend route at /dashboard and an API client helper to fetch dashboard stats.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
Frontend/src/views/dashboard/UserDashboard.jsx New dashboard UI rendering user stats and recent submissions from the new API.
Frontend/src/App.jsx Adds protected /dashboard route to render the new UserDashboard page.
Frontend/src/api/api.js Adds getUserDashboardStats() API client wrapper.
backend/src/api/submission/submission-service.ts Implements handleGetUserDashboardStats DB queries and response formatting.
backend/src/api/submission/submission-route.ts Registers the new /user/dashboard submission route (JWT-protected).
backend/src/api/submission/submission-controller.ts Adds controller handler to serve dashboard stats response.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

function Counter({ target, duration = 1200 }) {
const [val, setVal] = useState(0);
useEffect(() => {
if (!target) return;
Comment on lines +170 to +174
const solved = stats?.solvedByDifficulty ?? { easy: 0, medium: 0, hard: 0 };
const totalSolved = stats?.totalSolved ?? 0;
const acceptRate = stats?.totalSubmissions
? Math.round((totalSolved / stats.totalSubmissions) * 100)
: 0;
Comment on lines +244 to +263
{[
{ label: "Easy", count: solved.easy, color: "bg-emerald-500", text: "text-emerald-400", total: 100 },
{ label: "Medium", count: solved.medium, color: "bg-amber-500", text: "text-amber-400", total: 100 },
{ label: "Hard", count: solved.hard, color: "bg-rose-500", text: "text-rose-400", total: 100 },
].map(({ label, count, color, text, total }) => (
<div key={label} className="space-y-1">
<div className="flex justify-between text-xs">
<span className={`font-semibold ${text}`}>{label}</span>
<span className="text-slate-400 tabular-nums">
{loading ? "—" : count} <span className="text-slate-600">/ {total}</span>
</span>
</div>
<div className="h-2 rounded-full bg-white/5 overflow-hidden">
<div
className={`h-full rounded-full ${color} transition-all duration-1000`}
style={{ width: loading ? "0%" : `${Math.min((count / total) * 100, 100)}%` }}
/>
</div>
</div>
))}
import { db } from '../../loaders/postgres';
import redis from '../../loaders/redis';
import { eq, and, desc } from 'drizzle-orm';
import { eq, and, desc, count, sql } from 'drizzle-orm';
Comment on lines +226 to +251
// Accepted problems (distinct problems with ACCEPTED verdict)
const acceptedProblems = await db
.selectDistinct({ problemId: submission.problemId })
.from(submission)
.innerJoin(executionResult, eq(executionResult.submissionId, submission.id))
.where(and(
eq(submission.userId, userId),
eq(submission.mode, 'SUBMIT'),
eq(executionResult.verdict, 'ACCEPTED')
));

// Group accepted by difficulty
const acceptedWithDiff = await db
.selectDistinct({ problemId: submission.problemId, difficulty: problem.difficulty })
.from(submission)
.innerJoin(executionResult, eq(executionResult.submissionId, submission.id))
.innerJoin(problem, eq(problem.id, submission.problemId))
.where(and(
eq(submission.userId, userId),
eq(submission.mode, 'SUBMIT'),
eq(executionResult.verdict, 'ACCEPTED')
));

const easyCount = acceptedWithDiff.filter(r => r.difficulty === 'EASY').length;
const mediumCount = acceptedWithDiff.filter(r => r.difficulty === 'MEDIUM').length;
const hardCount = acceptedWithDiff.filter(r => r.difficulty === 'HARD').length;
Comment on lines +276 to +281
return {
totalSubmissions: 0,
totalSolved: 0,
solvedByDifficulty: { easy: 0, medium: 0, hard: 0 },
recentSubmissions: [],
};
Comment on lines +58 to +61
success: true,
data: response,
});
});
Comment on lines +2 to +8
import { Link, useNavigate } from "react-router-dom";
import { useAuth } from "@/hooks/AuthContext";
import { getUserDashboardStats } from "@/api/api";
import {
Trophy, Code2, CheckCircle2, XCircle, Clock, Cpu,
ChevronRight, BarChart3, User, Zap, BookOpen,
MessageSquare, Target, TrendingUp, Calendar, Star
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants